package com.zengshuai.miniprogrambackend.Controller;

import com.zengshuai.miniprogrambackend.Entity.Service;
import com.zengshuai.miniprogrambackend.Mapper.ServiceMapper;
import com.zengshuai.miniprogrambackend.Service.myService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/service")
public class ServiceController {
    @Autowired
    ServiceMapper serviceMapper;

    @Autowired
    myService myService;


    @GetMapping("/getservicelistbycategory/{category}")
    public List<Service> getservicelistbycategory(@PathVariable("category") int category) {


        return serviceMapper.getservicelistbycategory(category);
    }

    @GetMapping("/getservicebyserviceid/{serviceid}")
    public Service getservicebyserviceid(@PathVariable("serviceid") int serviceid) {


        return serviceMapper.getservicebyserviceid(serviceid);
    }


    @GetMapping("/getserviceswiperbyserviceid/{serviceid}")
    public Map<String, String> getServiceSwiper(@PathVariable("serviceid") int serviceid) {


        return myService.getServiceSwiper(serviceid);
    }


    @GetMapping("/search")
    public Service search(String keyword) {


        System.out.println(keyword);
        System.out.println(serviceMapper.search(keyword));

        return serviceMapper.search(keyword);


    }


}
